package cn.iocoder.yudao.module.member.dal.mysql.userrelation;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.userrelation.UserRelationDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.userrelation.vo.*;

/**
 * 户关系 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserRelationMapper extends BaseMapperX<UserRelationDO> {

    default PageResult<UserRelationDO> selectPage(UserRelationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserRelationDO>()
                .eqIfPresent(UserRelationDO::getMemberUserId, reqVO.getMemberUserId())
                .eqIfPresent(UserRelationDO::getCrmMemberUserId, reqVO.getCrmMemberUserId())
                .eqIfPresent(UserRelationDO::getRelation, reqVO.getRelation())
                .eqIfPresent(UserRelationDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(UserRelationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserRelationDO::getId));
    }

    default List<UserRelationDO> selectList(UserRelationExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserRelationDO>()
                .eqIfPresent(UserRelationDO::getMemberUserId, reqVO.getMemberUserId())
                .eqIfPresent(UserRelationDO::getCrmMemberUserId, reqVO.getCrmMemberUserId())
                .eqIfPresent(UserRelationDO::getRelation, reqVO.getRelation())
                .eqIfPresent(UserRelationDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(UserRelationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserRelationDO::getId));
    }

}
